package hari4.tes.soal2;

import java.util.*;

public class PrimeFactors {
	 public static void main(String[] args) {
	 
		 System.out.print("Masukkan Angka :");
	 	int n = Integer.parseInt(BacaKeyboard.bacaString());
	 	System.out.println();
	 	
        List<Integer> factors = new ArrayList<Integer>();
        Set set = new LinkedHashSet(factors);
      
        int counter = 0; int penandaPrime = 0;

        System.out.print("The prime factorization of " + n + " is: ");
        int i = 2;
        if(n%i != 0 || n == 2){
        	penandaPrime = 1;
        	System.out.println("Prime");
        }
        else{
        	Set x = new HashSet();
        	for (int a = 2; a <= n / a; a++) {                    
        		while (n % a == 0) {
	                n = n / a;
	               
	                x.add(a);
	                
	               
	        }
	        	 
	     }
        System.out.print(x+ " ");

	        if ((n > 1) && (penandaPrime != 1)) System.out.println(n);
	        else       System.out.println();
        }     
	 }
}
